package com.hp.easyBuy.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hp.easyBuy.entity.TGoods;
import com.hp.easyBuy.service.GoodsService;
import com.hp.easyBuy.utils.R;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/*
* 商品部分的控制器
* */
@RestController
@RequestMapping("goods")
public class GoodsController {
    @Resource
    private GoodsService goodsService;

    //获取单件商品数据展示在页面上
    @RequestMapping("show")
    public R show(Integer goodsid){
        TGoods byId = goodsService.getById(goodsid);
        return R.success(byId);
    }


    //获取商品的分页数据
    @PostMapping("doPage")
    public R doPage(@RequestParam Integer currentpage, @RequestParam Integer pagesize, @RequestBody Map<String,Object> params){
        Page<TGoods> page = goodsService.doPage(currentpage, pagesize, params);
        return R.success(page);
    }
}
